package com.ttx.springmvc.example2.controller;

import com.ttx.springmvc.example2.model.JsonModel;
import com.ttx.springmvc.example2.model.User;
import com.ttx.springmvc.example2.model.ValidateModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import java.util.Date;

/**
 * @author TimFruit
 */
@Api(value = "/validate", tags="测试验证模块")

@Controller
@RequestMapping("/validate")
@Slf4j


@Validated //注解
public class ValidateController {


    @ApiOperation(value = "/get", notes = "")
    @GetMapping("/get")
    @ResponseBody
    public void get(@RequestParam("id") @Min(value = 1L, message = "编号必须大于 0") Integer id) {
        log.info("[get][id: {}]", id);
    }

    @ApiOperation(value = "/add", notes = "")
    @PostMapping("/add")
    @ResponseBody
    public void add(@Valid ValidateModel addDTO) {
        log.info("[add][addDTO: {}]", addDTO);
    }



}
